#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
using ll = long long;
using T = int;
T rad(); // quick read
const int inf = 0x3f3f3f3f;
#define rf(i, n) for (int i = 1; i <= (n); ++i)
const int maxn = 5 + 2e5;

struct Node {
    int val, id;
    bool operator<(const Node &r) const { return val != r.val ? val < r.val : id < r.id; }
};

int n, m;
Node a[maxn << 1];
int cnt[maxn];

int main() {
    int Q = rad();
    rf(q, Q) {
        n = rad(), m = rad();
        rf(i, n) {
            a[i].val = rad(), a[i].id = i;
            a[i + n].val = rad(), a[i + n].id = i;
        }
        sort(a + 1, a + 1 + 2 * n);
        memset(cnt, 0, sizeof(cnt));

        int l = 1, r = 1;
        ll num = 0;
        for (; num < n; ++r)
            if (++cnt[a[r].id] == 1) num++;

        while ((ll)a[l].val * 100 < (ll)a[r - 1].val * m) {
            if (--cnt[a[l].id] == 0) --num;
            ++l;
        }

        ll ans = 0;
        for (ans = num; r <= 2 * n; ++r) {
            if (++cnt[a[r].id] == 1) ++num;
            while ((ll)a[l].val * 100 < (ll)a[r].val * m) {
                if (--cnt[a[l].id] == 0) --num;
                ++l;
            }
            ans = max(ans, num);
        }

        printf("Case #%d: %lld\n", q, ans);
    }
}

T rad() {
    T back = 0;
    int ch = 0, posi = 0;
    for (; ch < '0' || ch > '9'; ch = getchar())
        posi = ch ^ '-';
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        back = (back << 1) + (back << 3) + (ch & 0xf);
    return posi ? back : -back;
}